package org.kou.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.kou.bean.ShoppingBean;
import org.kou.servlet.ShoppingLogin;
import org.sen.utils.PublicUtils;

import com.alibaba.fastjson.JSON;

/**
 * Servlet implementation class QueryChat 获取仓库中购物记录表中的数据操作，展示商品
 */
@WebServlet("/Queryshopppingrecord")
public class Queryshopppingrecord extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取仓库记录内容
		ShoppingBean admink = PublicUtils.convertFormData2Bean(request, ShoppingBean.class);
		List<ShoppingBean> lstAdmins = PublicUtils.getInstance(ShoppingLogin.class).queryLoginInfo(admink);
		System.out.println("查询结果：" + lstAdmins);
		// 借助第三方的工具将集合转换为json字符串【alibaba的fastjson插件包】
		// 将查询结果集list转换为json字符串
		String strJson = JSON.toJSONString(lstAdmins);
		// ajax响应
		// 响应客户单的请求
		PrintWriter pw = response.getWriter();
		// 将json字符串发回客户端浏览器
		pw.write(strJson);
	}
}